package com.tj.work.oracletest.controller;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.tj.work.oracletest.common.vo.PageResDTO;
import com.tj.work.oracletest.common.vo.PageVO;
import com.tj.work.oracletest.common.vo.ResponseVo;
import com.tj.work.oracletest.dao.OracleMapper;
import com.tj.work.oracletest.model.TjTest2;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;
import javax.xml.transform.Result;
import javax.xml.ws.Response;
import java.util.List;
import java.util.Map;

/**
 * @author tangjing
 * @date 2021/09/28 17:19
 */
@RestController
@RequestMapping("/oracle")
@Api(tags = "oracle测试接口")
@Slf4j
public class OracleTestController {

    @Resource
    private OracleMapper oracleMapper;

    @PostMapping("/testOut")
    @ApiOperation(value = "查询简单输出")
    public ResponseVo<String> pageBanner() {
        return ResponseVo.content("hello,oracle");
    }

    @PostMapping("/pageOracle")
    @ApiOperation(value = "分页查询")
    public ResponseVo<PageResDTO<TjTest2>> pageOracle(@RequestBody @Valid PageVO pageVO) {
        PageHelper.startPage(pageVO.getPageNum(),pageVO.getPageSize());
        List<TjTest2> info = oracleMapper.selectList();
        PageInfo<TjTest2> pageInfo = new PageInfo<>(info);
        return ResponseVo.content(new PageResDTO<>(pageInfo.getTotal(),pageInfo.getList()));
    }


}
